//
//  CWSearchView.swift
//  新浪微博练习02
//
//  Created by 曹魏 on 16/9/24.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit
/*
 @IBDesignable 让可视化属性实时刷新
 @IBInspectable 定义可视化属性
 
 
 */
@IBDesignable class CWSearchView: UIButton {
    
//    @IBInspectable var cornerRadius:CGFloat {
//        set {
//            //设置layer的圆角属性
//            layer.cornerRadius = newValue
//            layer.masksToBounds = newValue > 0
//        }
//        get {
//            return layer.cornerRadius
//        }
//    }
    
    
    
    
    //定义类方法加载视图的xib文件
    class func loadSearchView() -> CWSearchView{
        let nib = UINib(nibName: "CWSearchView", bundle: nil)
        let searchView = nib.instantiate(withOwner: nil, options: nil).last as!CWSearchView
        
        return searchView
    }
    //xib文件加载完成会调用下面的方法,激活视图
    override func awakeFromNib() {
        //完成视图的布局,设置图片的内边距
        self.imageEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)
        //设置文字的内边距
        self.titleEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 0)
        //代码设置宽度
        self.bounds.size.width = UIScreen.main.bounds.width
        //设置圆角
//        self.layer.cornerRadius = 17
//        //切
//        self.layer.masksToBounds = true
        
    }

}












